home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
mc51bugs.zip
/
Q40113
< prev
next >
Wrap
Text File
|
1989-01-06
|
2KB
|
58 lines
Q40113 Incorrect Code Generation with /J
C Compiler
5.00 5.10 | 5.10
MS-DOS | OS/2
Summary:
If the following program is compiled with the /J compiler option
(which changes the default for char type from signed to unsigned) in
the Microsoft C Optimizing Compiler Versions 5.00 and 5.10, it will
not calculate the value of the long integer variable "result"
correctly:
#include <stdio.h>
void main(void)
{
unsigned long result = 'b';
result = result - 'a' + 1 ;
printf("result = %lx", result) ;
}
Compiled without /J, the program works correctly. Replacing "-a+1"
with "-96", or using a char type variable to store the value "a" also
prevents the problem.
Microsoft has confirmed this to be a problem in Versions 5.00 and
5.10. We are researching this problem and will post new information as
it becomes available.
More Information:
The following is the assembly-code listing generated with /J :
;|*** unsigned long result = 'b';
mov WORD PTR [bp-4],98 ;result
mov WORD PTR [bp-2],0
;|***
;|*** result = result - 'a' + 1 ;
add WORD PTR [bp-4],-96 ;This sets the carry flag
;incorrectly.
adc WORD PTR [bp-2],0
The following is the code generated without /J :
;|*** unsigned long result = 'b';
mov WORD PTR [bp-4],98 ;result
mov WORD PTR [bp-2],0
;|***
;|*** result = result - 'a' + 1 ;
sub WORD PTR [bp-4],96 ;result
sbb WORD PTR [bp-2],0
Keywords: buglist5.00 buglist5.10
Updated 89/01/06 07:29